package com.sky.controller.admin;

import com.sky.dto.OrdersSubmitDTO;
import com.sky.result.Result;
import com.sky.service.WorkspaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.SetmealOverViewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jdk.javadoc.internal.doclets.toolkit.OverviewElement;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * 目标:
 *
 * @author YUE
 * @date 2024/6/23 18:29
 */
@RestController
@Slf4j
@Api(tags = "工作台相关接口")
@RequestMapping("/admin/workspace")
public class WorkspaceController {
    @Autowired
    public WorkspaceService workspaceService;

    /*
       查询今日运营数据
     */
    @GetMapping("/businessData")
    @ApiOperation("查看今日运营数据")
    public Result<BusinessDataVO> businessData() {
        LocalDateTime beginTime = LocalDateTime.now().with(LocalTime.MIN);  // 一天 最早的时间

        LocalDateTime endTime = LocalDateTime.now().with(LocalTime.MAX);  // 一天 最早的时间

        BusinessDataVO businessDataVO = workspaceService.getBusinessData(beginTime, endTime);
        return Result.success(businessDataVO);
    }

    /*
       查看当天套餐总概览
     */
    @GetMapping("/overviewSetmeals")
    @ApiOperation("查看套餐总概览")
    public Result<SetmealOverViewVO> overviewSetmeals() {
        LocalDateTime beginTime = LocalDateTime.now().with(LocalTime.MIN);  // 一天 最早的时间

        LocalDateTime endTime = LocalDateTime.now().with(LocalTime.MAX);

        SetmealOverViewVO setmealOverViewVO = workspaceService.getSetmeals(beginTime, endTime);
        return Result.success(setmealOverViewVO);
    }

    /*
      查看菜品总概览
     */
    @GetMapping("/overviewDishes")
    @ApiOperation("查看菜品总概览")
    public Result<SetmealOverViewVO> overviewDishes() {
        SetmealOverViewVO setmealOverViewVO = workspaceService.getOrders();
        return Result.success(setmealOverViewVO);
    }
    /*
       查询订单管理数据
     */
    @GetMapping("/overviewOrders")
    @ApiOperation("查询订单管理数据")
    public Result<OrderOverViewVO> overviewOrders(){
        LocalDateTime beginTime = LocalDateTime.now().with(LocalTime.MIN);  // 一天 最早的时间

        LocalDateTime endTime = LocalDateTime.now().with(LocalTime.MAX);

      OrderOverViewVO orderOverViewVO = workspaceService.getByOrders(beginTime,endTime);
      return Result.success(orderOverViewVO);
    }
}

